home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 13 April 1997
- // Author: jb
- //
- //
- //<doc>
- //<name setState>
- //<owner "Alias|Wavefront Unsupported">
- //
- //<synopsis>
- // setState( string $type, int $state )
- //
- //<returns>
- // None.
- //
- //<description>
- // Sets the nodeState attr for all nodes in the
- // scene that match the type passed in.
- //<P>
- // Note that setting the state for certain types of nodes
- // can have unpredictable results (things will stop building,
- // evaluating, etc, and it can be difficult to determine
- // what is happening in the scene in certain complex cases).
- // Use this mainly for things like expressions, etc.
- //
- //<flags>
- // string $type : type of node to operate on.
- // valid choices are: iksolver, constraint, expression, particle,
- // rigidbody, snapshot or "all", which will do all of the above.
- //
- // int $state : state to set for the node.
- // "off" will turn the node off ("blocking" mode),
- // and "on" will turn the node on ("normal" mode).
- //
- //<examples>
- // setState "expression" on;
- //
- //</doc>
-
- proc setStates( string $typeList[], int $state, string $stateAttr,
- int $on, int $off, int $preOn)
- {
- string $node;
- string $type;
- string $nodes[];
-
- for ( $type in $typeList ) {
- string $cmd = "ls -type " + $type;
-
- if ( 0 == catch( $nodes = `eval $cmd` ) ) {
- for ( $node in $nodes ) {
- if ( $state ) {
- if ( $preOn != $on ) {
- setAttr ( $node + $stateAttr ) $preOn;
- }
- setAttr ( $node + $stateAttr ) $on;
- } else {
- setAttr ( $node + $stateAttr ) $off;
- }
- }
- }
- }
- }
-
-
-
- global proc setState( string $type, int $state )
- {
- string $nodes[];
- switch( $type ) {
- case "all":
- setState "constraint" $state;
- setState "expression" $state;
- setState "fluid" $state;
- setState "globalstitch" $state;
- setState "iksolver" $state;
- setState "particle" $state;
- setState "rigidbody" $state;
- setState "snapshot" $state;
- break;
- case "iksolver":
- ikSystem -e -sol $state;
-
- // update the checkBox status in Skeleton menu.
- //
- if( `menuItem -exists globalSolveEnableItem` ) {
- catch(`menuItem -e -cb $state globalSolveEnableItem`);
- }
- break;
- case "constraint":
- string $twoOffConstraints[] = { "pointConstraint",
- "aimConstraint",
- "orientConstraint",
- "parentConstraint",
- "scaleConstraint",
- "normalConstraint",
- "tangentConstraint " };
- setStates( $twoOffConstraints, $state, ".nodeState", 0, 2, 2 );
-
- string $oneOffConstraints[] = { "geometryConstraint" };
- setStates( $oneOffConstraints, $state, ".nodeState", 0, 1, 1 );
-
- break;
- case "expression":
- $nodes = `ls -type expression`;
- for( $node in $nodes )
- {
- if( $state ) {
- setAttr ( $node + ".nodeState" ) 1;
- setAttr ( $node + ".nodeState" ) 0;
- } else {
- setAttr ( $node + ".nodeState" ) 2;
- }
-
- // Expressions sometimes have intervening unit conversion
- // nodes, so make sure they get the same blocked/normal
- // state as the expression driving them.
- //
- string $units[] = `listConnections
- -skipConversionNodes 0
- -source 0 -destination 1
- ($node+".output")`;
- for ($unit in $units)
- {
- if ((nodeType($unit) == "unitConversion") ||
- (nodeType($unit) == "timeToUnitConversion") ||
- (nodeType($unit) == "unitToTimeConversion"))
- {
- if( $state ) {
- setAttr ( $unit + ".nodeState" ) 1;
- setAttr ( $unit + ".nodeState" ) 0;
- } else {
- setAttr ( $unit + ".nodeState" ) 2;
- }
- }
- }
- }
- break;
- case "fluid":
- $nodes = `ls -type fluidShape`;
- for( $node in $nodes ) {
- if ($state) {
- setAttr ( $node + ".disableInteractiveEval" ) 0;
- } else {
- setAttr ( $node + ".disableInteractiveEval" ) 1;
- }
- }
- break;
- case "globalstitch":
- if ($state) {
- performanceOptions -disableStitch off;
- } else {
- performanceOptions -disableStitch on;
- }
- break;
- case "particle":
- if( `isTrue DynamicsExists` ) {
-
- $nodes = `ls -type particle`;
- for( $node in $nodes ) {
- if ($state) {
- setAttr ( $node + ".isDynamic" ) 1;
- } else {
- setAttr ( $node + ".isDynamic" ) 0;
- }
- }
- }
- break;
- case "rigidbody":
- if( `isTrue DynamicsExists` ) {
- $nodes = `ls -type rigidSolver`;
- for( $node in $nodes ) {
- if ($state) {
- setAttr ( $node + ".state" ) 1;
- } else {
- setAttr ( $node + ".state" ) 0;
- }
- }
-
- }
- break;
- case "snapshot":
- $nodes = `ls -type snapshot`;
- for( $node in $nodes ) {
- if ($state) {
- setAttr ( $node + ".nodeState" ) 1;
- setAttr ( $node + ".nodeState" ) 0;
- } else {
- setAttr ( $node + ".nodeState" ) 2;
- }
- }
- break;
- }
- }
-